#include"p.h"
const int total = 100;
typedef void (*func_t) (int);

void download(func_t pb){
  int cur = 0;
  while(cur<=total){
    pb(cur*1.0/total*100);
    if(cur==100) break;
    cur = cur+rand()%5;
    if(cur>100) cur = 100;
    usleep(rand()%200000+300000);
  }
  clear();
}


int main(){
  srand(time(0));
  printf("download in 1:\n");
  download(processBar);
  printf("download in 2:\n");
  download(processBar);
  printf("download in 3:\n");
  download(processBar);
  return 0;
}
